package cn.iocoder.yudao.module.trade.service.drainage;

import cn.iocoder.yudao.module.trade.controller.admin.orderpostback.vo.OrderPostBackSaveReqVO;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.orderpostback.OrderPostBackDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.orderpostconfig.OrderPostConfigDO;
import cn.iocoder.yudao.module.trade.enums.orderpostback.TradeOrderPostBackStatusEnum;
import com.alibaba.fastjson.JSONObject;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

public interface DrainageService {

    boolean processOrder(TradeOrderDO orderDO, Map<String, String> param, OrderPostConfigDO configDO, boolean send);

    boolean processOrder(OrderPostBackDO orderPostBackDO);

    boolean unPayOrderPost(TradeOrderDO tradeOrderDO, Map<String, String> param, OrderPostConfigDO configDO);

    Integer getDrainageType();

    default OrderPostBackSaveReqVO createOrderPostBack(TradeOrderDO tradeOrderDO, String thirdId, Integer drainageType,
                                                       Integer postPrice, Integer orderType, OrderPostConfigDO configDO,
                                                       TradeOrderPostBackStatusEnum statusEnum) {
        OrderPostBackSaveReqVO saveReqVO = new OrderPostBackSaveReqVO();
        saveReqVO.setOrderId(tradeOrderDO.getId());
        saveReqVO.setDrainageConfigId(configDO.getId());
        saveReqVO.setDrainageCode(configDO.getDrainageCode());
        saveReqVO.setOrderType(orderType);
        saveReqVO.setPostPrice(postPrice);
        saveReqVO.setPayPrice(tradeOrderDO.getPayPrice());
        saveReqVO.setThirdId(thirdId);
        saveReqVO.setThirdType(drainageType);
        saveReqVO.setStatus(statusEnum.getStatus());
        saveReqVO.setOrderDate(LocalDate.now());
        saveReqVO.setOrderTime(LocalDateTime.now());
        return saveReqVO;
    }
}
